<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('劳资填报管理')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="costCode-form">
                <div class="select-list">
                    <ul>
                        <li>
                            项目名称：<input type="text" name="codeNum"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()">
                <i class="fa fa-plus"></i> 新增项目
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "capitalManage";

    $(function () {
        var options = {
            code: "id",
            parentCode: "parentId",
            uniqueId: "id",
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            importUrl: prefix + "/importData",
            modalName: "项目",
            expandAll: false,//是否全部展示
            expandFirst: false,//不展开二级
            striped: true,//是否显示行间色
            columns: [{
                field: 'selectItem',
                radio: true
            },

                {
                    field: 'pro_name',
                    title: '项目名称',
                    align: "left"
                },
                {
                    field: 'pro_position',
                    title: '项目位置',
                    align: "left"
                },
                {
                    field: 'pro_type',
                    title: '项目类型',
                    align: "left"
                },
                {
                    field: 'capital_person',
                    title: '劳资负责人',
                    align: "left"
                },
                {
                    field: 'id',
                    title: 'id',
                    visible : false
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        if (row.pro_name == '工种') {
                            var actions = [];
                            var url = ctx + "capitalManage/toAddWork?typeId=" + row.id
                            var title = '新增工种';
                            actions.push('<a class="btn btn-info  btn-xs "href="javascript:void(0)" onclick="$.modal.open(\'' + title + '\',\'' + url + '\',500,500)"><i class="fa fa-plus"></i>新增工种</a> ');
                            return actions.join('');
                        } else if(row.pro_name == '施工部位'){
                            var actions = [];
                            var url = ctx + "capitalManage/toAddPosition?typeId=" + row.id;
                            var title = '新增施工部位';
                            actions.push('<a class="btn btn-info  btn-xs "href="javascript:void(0)" onclick="$.modal.open(\'' + title + '\',\'' + url + '\',500,500)"><i class="fa fa-plus"></i>新增施工部位</a> ');
                            return actions.join('');
                        } else if(row.orders == '3' || row.orders == '4'){
                            var actions = [];
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.treeTable.init(options);
    });

    function add() {
        $.operate.open($.modal.open('新增项目',prefix + '/toAddPro'));
    }
</script>
</body>
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>